<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasPermissions;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;
//    use HasPermissions;
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password', 'auth',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    protected $appends = [
        'auth_name'
    ];

    public function getAuthNameAttribute($value)
    {
        return $this->authList()[$this->attributes['auth']];
    }

    public  function authList()
    {
        $list = [
            '0' => '业务员',
            '1' => '审核员',
            '2' => '经理',
            '3' => '总经理',
            '4' => '财务',
            '5' => '催收人员'
        ];

        return $list;
    }
}
